package com.cee.service.Impl;

import com.cee.dao.JudgeMapper;
import com.cee.dto.JudgeDTO;
import com.cee.model.Judge;
import com.cee.service.JudgeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;


@Slf4j
@Service
@Transactional
public class JudgeServiceImpl implements JudgeService {

    @Autowired
    private JudgeMapper judgeMapper;

    @Override
    public int saveJudge(Judge judge) throws Exception {
       return judgeMapper.insert(judge);
    }

    @Override
    public List<JudgeDTO> getJudgeList(JudgeDTO judgeDTO) {
        return judgeMapper.getJudgeList(judgeDTO);
    }

    @Override
    public void deleteJudge(Integer id) {
        Judge judge = new Judge();
        judge.setId(id);
        judge.setDelDateTime(new Date());

        log.info("逻辑删除judge, id={}", id);
        judgeMapper.updateJudgeById(judge);
    }

    @Override
    public List<JudgeDTO> getListByExamId(Integer examId) {
        return judgeMapper.getListByExamId(examId);
    }
}
